ExtendedMarkdownInline   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A constructor 0 8 2
A pluginName 0 3 1
1
/*
2
 * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
3
 *
4
 *  Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
5
 *
6
 *  This program is free software: you can redistribute it and/or modify
7
 *  it under the terms of the GNU Affero General Public License as published
8
 *  by the Free Software Foundation, either version 3 of the License, or
9
 *  (at your option) any later version.
10
 *
11
 *  This program is distributed in the hope that it will be useful,
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 *  GNU Affero General Public License for more details.
15
 *
16
 *  You should have received a copy of the GNU Affero General Public License
17
 *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
import { Plugin } from 'ckeditor5/src/core';
21
import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
22
23
const ALLOWED_TAGS = [
24
	//Common elements
25
	'sup',
26
	'sub',
27
	'u',
28
	'kbd',
29
	'mark',
30
	'ins',
31
	'small',
32
	'abbr',
33
	'br',
34
	'span',
35
];
36
37
38
/**
39
 * The GitHub Flavored Markdown (GFM) plugin with added HTML tags, which are kept in the output. (inline mode)
40
 *
41
 */
42
export default class ExtendedMarkdownInline extends Plugin {
43
	/**
44
	 * @inheritDoc
45
	 */
46
	constructor( editor ) {
47
		super( editor );
48
49
		editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
50
		for (const tag of ALLOWED_TAGS) {
51
			editor.data.processor.keepHtml(tag);
52
		}
53
	}
54
55
	/**
56
	 * @inheritDoc
57
	 */
58
	static get pluginName() {
59
		return 'Markdown';
60
	}
61
}
62